package us.pinguo.loader;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.ImageSwitcher;
import android.widget.ImageView;

import com.nostra13.universalimageloader.cache.disc.DiskCache;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.MemoryCache;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.assist.ViewScaleType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme;
import com.nostra13.universalimageloader.core.imageaware.ImageAware;
import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;
import com.nostra13.universalimageloader.core.imageaware.NonViewAware;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
import com.nostra13.universalimageloader.utils.ImageSizeUtils;
import com.nostra13.universalimageloader.utils.MemoryCacheUtils;
import com.nostra13.universalimageloader.utils.StorageUtils;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;

import us.pinguo.loader.core.display.BlurBitmapDisplayer;
import us.pinguo.loader.core.display.BlurFadeInBitmapDisplayer;
import us.pinguo.loader.core.display.CircleBitmapDisplayer;
import us.pinguo.loader.core.display.CircleBlurBitmapDisplayer;
import us.pinguo.loader.core.display.CircleFadeInBitmapDisplayer;
import us.pinguo.loader.core.display.CircleRingBitmapDisplayer;
import us.pinguo.loader.core.display.RoundedBitmapDisplayer;
import us.pinguo.loader.core.display.RoundedBlurBitmapDisplayer;
import us.pinguo.loader.core.display.RoundedFadeInBitmapDisplayer;
import us.pinguo.loader.core.display.RoundedLomoBitmapDisplayer;
import us.pinguo.loader.core.display.RoundedLomoBlurBitmapDisplayer;
import us.pinguo.loader.core.display.RoundedLomoFadeInBitmapDisplayer;
import us.pinguo.loader.core.generator.SimpleFileNameGenerator;
import us.pinguo.loader.core.imageaware.ImageSwitcherAware;
import us.pinguo.loader.core.imageaware.SimpleViewAware;

/**
 * time: 15/6/11 
 * description:图片加载对外提供的入口API
 *
 * @author fandong
 */
public class PinguoImageLoader {
	public static final int DISPLAY_DEFAULT = 1;
	public static final int DISPLAY_FADE_IN = 2;
	public static final int DISPLAY_ROUND = 3;
	public static final int DISPLAY_ROUND_FADE_IN = 4;
	public static final int DISPLAY_ROUND_VIGNETTE = 5;
	public static final int DISPLAY_ROUND_VIGNETTE_FADE_IN = 6;
	public static final int DISPLAY_CIRCLE = 7;
	public static final int DISPLAY_CIRCLE_FADE_IN = 8;
	public static final int DISPLAY_CIRCLE_RING = 9;
	public static final int DISPLAY_BLUR = 10;
	public static final int DISPLAY_BLUR_FADE_IN = 11;
	public static final int DISPLAY_ROUND_BLUR = 12;
	public static final int DISPLAY_ROUND_BLUR_VIGNETTE = 13;
	public static final int DISPLAY_CIRCLE_BLUR = 14;
	private static Context mContext;
	private static ImageLoader mImageLoader;

	private PinguoImageLoader() {
	}

	public static synchronized void init(Context context, String cacheDir) {
		init(context, cacheDir, 134217728L);
	}

	public static synchronized void init(Context context, String cacheDir, long diskCacheSize) {
		mContext = context;
		mImageLoader = ImageLoader.getInstance();
		if (!mImageLoader.isInited()) {
			Options options = new Options();
			options.inPreferredConfig = Config.ARGB_8888;
			options.inSampleSize = 1;
			ImageLoaderConfiguration imageLoaderConfiguration = (new com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder(
					mContext))
					.threadPriority(4)
					.threadPoolSize(Runtime.getRuntime().availableProcessors() + 1)
					.tasksProcessingOrder(QueueProcessingType.LIFO)
					.diskCache(createDiskCache(context, cacheDir, new SimpleFileNameGenerator(), diskCacheSize))
					.memoryCache(createMemoryCache(25))
					.defaultDisplayImageOptions(
							(new com.nostra13.universalimageloader.core.DisplayImageOptions.Builder())
									.cacheInMemory(true).cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY)
									.considerExifParams(true).decodingOptions(options).build()).build();
			mImageLoader.init(imageLoaderConfiguration);
		}

	}

	private static MemoryCache createMemoryCache(int availableMemoryPercent) {
		long availableMemory = Runtime.getRuntime().maxMemory();
		return new LruMemoryCache((int) ((float) availableMemory * ((float) availableMemoryPercent / 100.0F)));
	}

	private static DiskCache createDiskCache(Context context, String cacheDir,
			FileNameGenerator diskCacheFileNameGenerator, long diskCacheSize) {
		File reserveCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		File preferredCacheDir = null;
		if (!TextUtils.isEmpty(cacheDir)) {
			preferredCacheDir = new File(cacheDir);
		} else {
			preferredCacheDir = reserveCacheDir;
		}

		Object diskCache = null;

		try {
			diskCache = new LruDiskCache(preferredCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					0);
		} catch (IOException var9) {
			var9.printStackTrace();
		}

		if (diskCache == null) {
			diskCache = new UnlimitedDiskCache(preferredCacheDir, reserveCacheDir, diskCacheFileNameGenerator);
		}

		return (DiskCache) diskCache;
	}

	public static void resume() {
		mImageLoader.resume();
	}

	public static void pause() {
		mImageLoader.pause();
	}

	public static void stop() {
		mImageLoader.stop();
	}

	public static void destory() {
		mImageLoader.destroy();
	}

	public static DiskCache getDiskCache() {
		return mImageLoader.getDiskCache();
	}

	public static MemoryCache getMemoryCache() {
		return mImageLoader.getMemoryCache();
	}

	public static long getUsedDiskCacheSize() {
		long size = 0L;
		DiskCache diskCache = mImageLoader.getDiskCache();
		File dir = diskCache.getDirectory();
		if (dir.exists() && dir.isDirectory()) {
			File[] files = dir.listFiles();
			File[] var8 = files;
			int var7 = files.length;

			for (int var6 = 0; var6 < var7; ++var6) {
				File file = var8[var6];
				if (file.isFile()) {
					size += file.length();
				}
			}
		}

		return size;
	}

	@SuppressWarnings("rawtypes")
	public static long getUsedMemoryCacheSize() {
		long size = 0L;
		MemoryCache memoryCache = mImageLoader.getMemoryCache();
		Iterator var4 = memoryCache.keys().iterator();

		while (var4.hasNext()) {
			String key = (String) var4.next();
			Bitmap bitmap = (Bitmap) memoryCache.get(key);
			if (bitmap != null && !bitmap.isRecycled()) {
				size += (long) (bitmap.getHeight() * bitmap.getRowBytes());
			}
		}

		return size;
	}

	public static void clearDiskCache() {
		mImageLoader.clearDiskCache();
	}

	public static void clearMemoryCache() {
		mImageLoader.clearMemoryCache();
	}

	private static ImageSize getMaxImageSize() {
		DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
		ImageSize maxImageSize = new ImageSize(displayMetrics.widthPixels, displayMetrics.heightPixels);
		return maxImageSize;
	}

	private static String getMemoryCacheKey(String uri, ImageAware imageAware) {
		if (imageAware == null) {
			imageAware = new NonViewAware(uri, getMaxImageSize(), ViewScaleType.CROP);
		}

		ImageSize targetSize = ImageSizeUtils.defineTargetSizeForView((ImageAware) imageAware, getMaxImageSize());
		String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
		return memoryCacheKey;
	}

	private static String getDiskCacheKey(String uri) {
		return uri;
	}

	public static boolean putMemoryCache(String key, Bitmap bitmap) {
		if (key == null) {
			return false;
		} else {
			MemoryCache memoryCache = mImageLoader.getMemoryCache();
			return memoryCache.put(getMemoryCacheKey(key, (ImageAware) null), bitmap);
		}
	}

    public static Bitmap getMemoryCache(String url){
        return getMemoryCache(url,null);
    }

	public static Bitmap getMemoryCache(String url, View view) {
		if (url == null) {
			return null;
		} else {
			MemoryCache memoryCache = mImageLoader.getMemoryCache();
			String mkey = null;
			if (view == null) {
				mkey = getMemoryCacheKey(url, new NonViewAware(getMaxImageSize(), ViewScaleType.CROP));
			} else if (view instanceof ImageView) {
				mkey = getMemoryCacheKey(url, new ImageViewAware((ImageView) view));
			} else {
				mkey = getMemoryCacheKey(url, new SimpleViewAware(view));
			}

			return (Bitmap) memoryCache.get(mkey);
		}
	}

    public static Bitmap getDiskCache(String url){
        return getDiskCache(url,null);
    }

	public static Bitmap getDiskCache(String url, View view) {
		if (url == null) {
			return null;
		} else {
			Bitmap bitmap = null;
			DiskCache diskCache = mImageLoader.getDiskCache();
			String dkey = getDiskCacheKey(url);
			File imageFile = diskCache.get(dkey);
			if (imageFile != null && imageFile.exists()) {
				ImageSize targetSize = null;
				if (view == null) {
					targetSize = getMaxImageSize();
				} else if (view instanceof ImageView) {
					targetSize = ImageSizeUtils.defineTargetSizeForView(new ImageViewAware((ImageView) view),
							getMaxImageSize());
				} else {
					targetSize = ImageSizeUtils.defineTargetSizeForView(new SimpleViewAware(view), getMaxImageSize());
				}

				bitmap = mImageLoader.loadImageSync(Scheme.FILE.wrap(imageFile.getAbsolutePath()), targetSize);
				if (bitmap != null && !bitmap.isRecycled()) {
					String mkey = null;
					if (view == null) {
						mkey = getMemoryCacheKey(url, new NonViewAware(getMaxImageSize(), ViewScaleType.CROP));
					} else if (view instanceof ImageView) {
						mkey = getMemoryCacheKey(url, new ImageViewAware((ImageView) view));
					} else {
						mkey = getMemoryCacheKey(url, new SimpleViewAware(view));
					}

					mImageLoader.getMemoryCache().put(mkey, bitmap);
				}
			}

			return bitmap;
		}
	}

	public static Bitmap getCache(String url, View view) {
		if (url == null) {
			return null;
		} else {
			Bitmap bitmap = null;
			bitmap = getMemoryCache(url, view);
			if (bitmap == null || bitmap.isRecycled()) {
				bitmap = getDiskCache(url, view);
			}

			return bitmap;
		}
	}

	private static void display(String url, View view) {
		display(url, view, 0);
	}

    private static void display(String url, View view, int defaultRes) {
		display(url, view, defaultRes, 1);
	}

    private static void display(String url, View view, int defaultRes, int displayType) {
		display(url, view, defaultRes, displayType, (ImageLoadingListener) null);
	}

    private static void display(String url, View view, int defaultRes, int displayType,
			ImageLoadingListener imageLoadingListener) {
		display(url, view, defaultRes, displayType, imageLoadingListener, (ImageLoadingProgressListener) null);
	}

    private static void display(String url, View view, int defaultRes, int displayType,
			ImageLoadingListener imageLoadingListener, ImageLoadingProgressListener imageLoadingProgressListener) {
		display(url, view, defaultRes, defaultRes, displayType, imageLoadingListener, imageLoadingProgressListener);
	}

    private static void display(String url, View view, int defaultRes, int failRes, int displayType,
			ImageLoadingListener imageLoadingListener, ImageLoadingProgressListener imageLoadingProgressListener) {
		display(url, view, defaultRes, failRes, defaultRes, displayType, imageLoadingListener,
				imageLoadingProgressListener);
	}

    private static void display(String url, View view, int defaultRes, int failRes, int emptyRes, int displayType,
			ImageLoadingListener imageLoadingListener, ImageLoadingProgressListener imageLoadingProgressListener) {
		create(url).setDefaultRes(defaultRes).setFailRes(failRes).setEmptyRes(emptyRes).setDisplayType(displayType)
				.setImageLoadinglistener(imageLoadingListener)
				.setImageLoadingProgressListener(imageLoadingProgressListener).into(view);
	}

    private static void display(String url, View view, DisplayImageOptions displayImageOptions) {
		display(url, view, displayImageOptions, (ImageLoadingListener) null, (ImageLoadingProgressListener) null);
	}

    private static void display(String url, View view, ImageLoadingListener imageLoadingListener) {
		display(url, view, (DisplayImageOptions) null, imageLoadingListener, (ImageLoadingProgressListener) null);
	}

    private static void display(String url, View view, DisplayImageOptions displayImageOptions,
			ImageLoadingListener imageLoadingListener) {
		display(url, view, displayImageOptions, imageLoadingListener, (ImageLoadingProgressListener) null);
	}

    private static void display(String url, View view, DisplayImageOptions displayImageOptions,
			ImageLoadingListener imageLoadingListener, ImageLoadingProgressListener imageLoadingProgressListener) {
		try {
			if (view instanceof ImageView) {
				mImageLoader.displayImage(url, new ImageViewAware((ImageView) view), displayImageOptions,
						imageLoadingListener, imageLoadingProgressListener);
			} else if (view instanceof ImageSwitcher) {
				mImageLoader.displayImage(url, new ImageSwitcherAware(view), displayImageOptions, imageLoadingListener,
						imageLoadingProgressListener);
			} else {
				mImageLoader.displayImage(url, new SimpleViewAware(view), displayImageOptions, imageLoadingListener,
						imageLoadingProgressListener);
			}
		} catch (OutOfMemoryError var6) {
			var6.printStackTrace();
		} catch (Exception var7) {
			var7.printStackTrace();
		}

	}

	public static void load(String url, ImageLoadingListener imageLoadingListener) {
		load(url, (ImageSize) null, (DisplayImageOptions) null, imageLoadingListener,
				(ImageLoadingProgressListener) null);
	}

	public static void load(String url, ImageSize targetImageSize, ImageLoadingListener imageLoadingListener) {
		load(url, targetImageSize, (DisplayImageOptions) null, imageLoadingListener,
				(ImageLoadingProgressListener) null);
	}

	public static void load(String url, DisplayImageOptions displayImageOptions,
			ImageLoadingListener imageLoadingListener) {
		load(url, (ImageSize) null, displayImageOptions, imageLoadingListener, (ImageLoadingProgressListener) null);
	}

	public static void load(String url, ImageSize targetImageSize, DisplayImageOptions displayImageOptions,
			ImageLoadingListener imageLoadingListener) {
		load(url, targetImageSize, displayImageOptions, imageLoadingListener, (ImageLoadingProgressListener) null);
	}

	public static void load(String url, ImageSize targetImageSize, DisplayImageOptions displayImageOptions,
			ImageLoadingListener imageLoadingListener, ImageLoadingProgressListener imageLoadingProgressListener) {
		try {
			mImageLoader.loadImage(url, targetImageSize, displayImageOptions, imageLoadingListener,
					imageLoadingProgressListener);
		} catch (OutOfMemoryError var6) {
			var6.printStackTrace();
		} catch (Exception var7) {
			var7.printStackTrace();
		}

	}

	public static Bitmap loadSync(String url, ImageSize targetImageSize, DisplayImageOptions displayImageOptions) {
		try {
			return mImageLoader.loadImageSync(url, targetImageSize, displayImageOptions);
		} catch (OutOfMemoryError var4) {
			var4.printStackTrace();
		} catch (Exception var5) {
			var5.printStackTrace();
		}

		return null;
	}

	public static PinguoImageLoader.Builder create(String url) {
		PinguoImageLoader.Builder builder = new PinguoImageLoader.Builder(url);
		return builder;
	}

	public static class Builder {
		private String mUrl;
		private int mDefaultRes;
		private int mFailRes;
		private int mEmptyRes;
		private Drawable mDefaultDrawable;
		private Drawable mFailDrawable;
		private Drawable mEmptyDrawable;
		private int mDisplayType = 1;
		private int mRoundRadius = 5;
		private int mBlurDepth = 10;
		private int mFadeInTime = 300;
		private ImageLoadingListener mImageLoadingListener;
		private ImageLoadingProgressListener mImageLoadingProgressListener;
		private ImageSize mImageSize;
		private ImageScaleType mImageScaleType;
		private Options decodingOptions;
		private float mStrokeWidth;
		private int mColor;
		private float mRingPadding;

		private Builder(String url) {
			this.mImageScaleType = ImageScaleType.EXACTLY;
			this.decodingOptions = new Options();
			this.mUrl = url;
			this.decodingOptions.inPreferredConfig = Config.RGB_565;
			this.decodingOptions.inSampleSize = 1;
		}

		public PinguoImageLoader.Builder setInSampleSize(int inSampleSize) {
			this.decodingOptions.inSampleSize = inSampleSize;
			return this;
		}

		public PinguoImageLoader.Builder setBitmapConfig(Config config) {
			this.decodingOptions.inPreferredConfig = config;
			return this;
		}

		public PinguoImageLoader.Builder setImageScaleType(ImageScaleType scaleType) {
			this.mImageScaleType = scaleType;
			return this;
		}

		public PinguoImageLoader.Builder setDefaultDrawable(Drawable drawable) {
			this.mDefaultDrawable = drawable;
			return this;
		}

		public PinguoImageLoader.Builder setFailDrawable(Drawable drawable) {
			this.mFailDrawable = drawable;
			return this;
		}

		public PinguoImageLoader.Builder setEmptyDrawable(Drawable drawable) {
			this.mEmptyDrawable = drawable;
			return this;
		}

		public PinguoImageLoader.Builder setDefaultRes(int res) {
			this.mDefaultRes = res;
			return this;
		}

		public PinguoImageLoader.Builder setFailRes(int res) {
			this.mFailRes = res;
			return this;
		}

		public PinguoImageLoader.Builder setEmptyRes(int res) {
			this.mEmptyRes = res;
			return this;
		}

		public PinguoImageLoader.Builder setDisplayType(int displayType) {
			this.mDisplayType = displayType;
			return this;
		}

		public PinguoImageLoader.Builder setRoundRadius(int roundRadius) {
			this.mRoundRadius = roundRadius;
			return this;
		}

		public PinguoImageLoader.Builder setBlurDepth(int blurDepth) {
			this.mBlurDepth = blurDepth;
			return this;
		}

		public PinguoImageLoader.Builder setFadeInTime(int fadeInTime) {
			this.mFadeInTime = fadeInTime;
			return this;
		}

		public PinguoImageLoader.Builder setImageLoadinglistener(ImageLoadingListener listener) {
			this.mImageLoadingListener = listener;
			return this;
		}

		public PinguoImageLoader.Builder setImageLoadingProgressListener(ImageLoadingProgressListener listener) {
			this.mImageLoadingProgressListener = listener;
			return this;
		}

		public PinguoImageLoader.Builder setImageSize(ImageSize imageSize) {
			this.mImageSize = imageSize;
			return this;
		}

		public PinguoImageLoader.Builder setStrokeWidth(float strokeWidth) {
			this.mStrokeWidth = strokeWidth;
			return this;
		}

		public PinguoImageLoader.Builder setColor(int color) {
			this.mColor = color;
			return this;
		}

		public PinguoImageLoader.Builder setRingPadding(float padding) {
			this.mRingPadding = padding;
			return this;
		}

		private DisplayImageOptions build() {
			if (this.mFailRes <= 0) {
				this.mFailRes = this.mDefaultRes;
			}

			if (this.mEmptyRes <= 0) {
				this.mEmptyRes = this.mDefaultRes;
			}

			if (this.mFailDrawable == null) {
				this.mFailDrawable = this.mDefaultDrawable;
			}

			if (this.mEmptyDrawable == null) {
				this.mEmptyDrawable = this.mDefaultDrawable;
			}

			com.nostra13.universalimageloader.core.DisplayImageOptions.Builder builder = (new com.nostra13.universalimageloader.core.DisplayImageOptions.Builder())
					.showImageOnFail(this.mFailDrawable).showImageForEmptyUri(this.mEmptyDrawable)
					.showImageOnLoading(this.mDefaultDrawable).showImageOnFail(this.mFailRes)
					.showImageForEmptyUri(this.mEmptyRes).showImageOnLoading(this.mDefaultRes)
					.imageScaleType(this.mImageScaleType).cacheInMemory(true).cacheOnDisk(true)
					.decodingOptions(this.decodingOptions).considerExifParams(true);
			DisplayImageOptions displayImageOptions = null;
			switch (this.mDisplayType) {
			case 1:// 简单
			default:
				displayImageOptions = builder.displayer(new SimpleBitmapDisplayer()).build();
				break;
			case 2:// 淡入
				displayImageOptions = builder.displayer(new FadeInBitmapDisplayer(this.mFadeInTime)).build();
				break;
			case 3:// 圆角矩形
				displayImageOptions = builder.displayer(new RoundedBitmapDisplayer(this.mRoundRadius)).build();
				break;
			case 4:// 圆角矩形淡入
				displayImageOptions = builder.displayer(
						new RoundedFadeInBitmapDisplayer(this.mRoundRadius, this.mFadeInTime)).build();
				break;
			case 5:// 圆角阴影(LOMO)
				displayImageOptions = builder.displayer(new RoundedLomoBitmapDisplayer(this.mRoundRadius)).build();
				break;
			case 6:// 圆角阴影淡入
				displayImageOptions = builder.displayer(
						new RoundedLomoFadeInBitmapDisplayer(this.mRoundRadius, this.mFadeInTime)).build();
				break;
			case 7:// 圆形
				displayImageOptions = builder.displayer(new CircleBitmapDisplayer()).build();
				break;
			case 8:// 圆形淡入
				displayImageOptions = builder.displayer(new CircleFadeInBitmapDisplayer(this.mFadeInTime)).build();
				break;
			case 9:// 圆形带环
				displayImageOptions = builder.displayer(
						new CircleRingBitmapDisplayer().setStrokeWidth(mStrokeWidth).setColor(mColor)
								.setRingPadding(mRingPadding)).build();
				break;
			case 10:// 高斯模糊
				displayImageOptions = builder.displayer(new BlurBitmapDisplayer(this.mBlurDepth)).build();
				break;
			case 11:// 高斯模糊淡入
				displayImageOptions = builder.displayer(
						new BlurFadeInBitmapDisplayer(this.mBlurDepth, this.mFadeInTime)).build();
				break;
			case 12:// 圆角高斯模糊
				displayImageOptions = builder.displayer(
						new RoundedBlurBitmapDisplayer(this.mRoundRadius, this.mBlurDepth)).build();
				break;
			case 13:// 圆角高斯模糊的LOMO
				displayImageOptions = builder.displayer(
						new RoundedLomoBlurBitmapDisplayer(this.mRoundRadius, this.mBlurDepth)).build();
				break;
			case 14:// 圆形高斯模糊
				displayImageOptions = builder.displayer(new CircleBlurBitmapDisplayer(this.mBlurDepth)).build();
			}

			return displayImageOptions;
		}

		public void load() {
			PinguoImageLoader.load(this.mUrl, this.mImageSize, this.build(), this.mImageLoadingListener,
					this.mImageLoadingProgressListener);
		}

		public void into(View view) {
			PinguoImageLoader.display(this.mUrl, view, this.build(), this.mImageLoadingListener,
					this.mImageLoadingProgressListener);
		}
	}

	public abstract static class DefaultLoadingListener implements ImageLoadingListener {
		public DefaultLoadingListener() {
		}

		public void onLoadingStarted(String s, View view) {
		}

		public void onLoadingFailed(String s, View view, FailReason failReason) {
		}

		public void onLoadingComplete(String s, View view, Bitmap bitmap) {
		}

		public void onLoadingCancelled(String s, View view) {
		}
	}
}
